package src.com.foreknow.demo21;

import java.util.*;

public class ExamCollection {
    public Map<String ,User> mi( Map<String,User> map1) {
//        Map<String,User> map1 = new HashMap<>();
//        User u1 = new User();
//        u1.setName("tom");
//        User u2 = new User();
//        u2.setName("fender");
//        //要将对象保存到Map容器中
//        map1.put("1",u1);
//        map1.put("2",u2);
        return map1;
    }
    public static void main(String[] args) {
        //创建下个List集合
        List<Map<String,User>> list  = new ArrayList<>();
        Map<String,User> map1 = new HashMap<>();
        User u1 = new User();
        u1.setName("tom");
        User u2 = new User();
        u2.setName("fender");
        //要将对象保存到Map容器中
        map1.put("1",u1);
        map1.put("2",u2);
        Map<String,User> map2 = new HashMap<>();
        User u3 = new User();
        u3.setName("gibson");
        User u4 = new User();
        u4.setName("yamaha");
        //要将对象保存到Map容器中
        map2.put("3",u3);
        map2.put("4",u4);
        Map<String,User> map3 = new HashMap<>();
        User u5 = new User();
        u5.setName("suhr");
        User u6 = new User();
        u6.setName("prs");
        //要将对象保存到Map容器中
        map3.put("5",u5);
        map3.put("6",u6);
        //将Map容器添加到List集合中
        list.add(map1);
        list.add(map2);
        list.add(map3);

        //遍历输出学生的信息
        //遍历List集合
        for(int i = 0;i<list.size();i++) {
            Map<String,User> map = list.get(i);
            Set<Map.Entry<String,User>> set = map.entrySet();
            Iterator<Map.Entry<String,User>> it = set.iterator();
            while (it.hasNext()) {
                Map.Entry<String,User> m = it.next();
                //获取到key和value
                String key = m.getKey();
                User user = m.getValue();
                System.out.println(key+"------"+user.getName());
            }
        }
    }
}
